package week4.num.ExceptionDemo01.neueduTotal.CardGame;

public class Card implements Comparable {
    /**
     * 创建变量代表纸牌的花色
     */
    private int suit;
    /**
     * 创建变量代表纸牌的点数
     */
    private int rank;
    /**
     * 创建常量记录纸牌各个花色代表的权值
     */
    public static final int FANGPAIN = 0;
    public static final int MEIHUA = 1;
    public static final int HONGTAO = 2;
    public static final int HEITAO = 3;
    public static final int JOKER = 4;
    /**
     * 创建常量记录纸牌各个点数所代表的权值
     */
    public static final int THREE = 0;
    public static final int FOUR = 1;
    public static final int FIVE = 2;
    public static final int SIX = 3;
    public static final int SEVEN = 4;
    public static final int EIGHT = 5;
    public static final int NIGHT = 6;
    public static final int TEN = 7;
    public static final int JACK = 8;
    public static final int QUEEN = 9;
    public static final int KING = 10;
    public static final int ONE = 11;
    public static final int TWO = 12;
    public static final int BLACK = 13;
    public static final int COLOR = 14;
    /**
     * 创建数组记录纸牌花色和点数,索引值为各自的权值
     */
    private static final String[] HUASE = {"♦", "♣", "♥", "♠", ""};
    private static final String[] DIANSHU = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2", "小王", "大王"};

    @Override
    public String toString() {
        return HUASE[suit] + DIANSHU[rank];
    }

    //arrays.sort排序调用
    @Override
    public int compareTo(Object o) {
        Card card = (Card) o;
        if (this.rank>card.rank) {
            return -1;
        }
        if (this.rank==card.rank) {
            if (this.suit > card.suit) {
                return -1;
            }
        }
        return 1;
    }

    public Card() {
    }

    public Card(int suit, int rank) {
        this.suit = suit;
        this.rank = rank;
    }
}
